home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7684 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: nntp.crl.com!usenet
  2. From: Richard Berman <sts@crl.com>
  3. Newsgroups: comp.object,comp.lang.c++
  4. Subject: Re: A design question
  5. Date: Sat, 24 Feb 1996 21:21:29 -0800
  6. Organization: Software Technology Service
  7. Message-ID: <312FF1D9.7B02@crl.com>
  8. References: <1996Feb22.234825.18755@dcs.warwick.ac.uk> <pvcybpuqx6p.fsf@hln56.pki-nbg.philips.de>
  9. NNTP-Posting-Host: crl11.crl.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win16; I)
  14.  
  15. Harald Wellmann wrote:
  16. > In article <1996Feb22.234825.18755@dcs.warwick.ac.uk> miro@dcs.warwick.ac.uk (Miroslav J Walker) writes:
  17. >    I'm trying to model input from a user being processed over a series of
  18. >    steps.
  19. >    Input is parsed, put into a queue and then interpreted on a timer. My
  20. >    question is how to model the idea of it being the same bit of data
  21. >    (essentially) taking on several forms as it proceeds along the 'pipeline' of
  22. >    processing.
  23. > There's a book called "Design Patterns" by Erich Gamma, where the pattern
  24. > you seem to be thinking of is called a "Chain of Responsibility".
  25. > (The book is very useful, I think, but maybe not for beginners.)
  26. > The idea of this pattern is to define a class `Event' encapsulating
  27. > the data to be processed along the chain.
  28. > Then there is an abstract base class `EventHandler' with methods
  29. > `forward(Event&)' and `process(Event&)' and an attribute
  30. > `EventHandler* next_handler'.
  31. > You can derive several types of event handlers from this class,
  32. > processing the event in a different way.
  33. > Then you construct instances of these handlers and link them to form a chain.
  34. > Each handler will process the event in its own style and then forward
  35. > it to the next handler.
  36. > For more details, read the book!
  37.  
  38. Of course, a state table might do the trick as well.
  39.  
  40.     -rb
  41. -- 
  42. ------------------------------------------------------------
  43. Richard Berman                       Vox: (213) 258-7525
  44. Software Technology Service          Fax: (213) 258-9483
  45. 3737 Division Street, Los Angeles, CA 90065
  46. sts@crl.com       <URL:http://www.crl.com/~sts/>
  47. ------------------------------------------------------------
  48.